package ai.people.core.security.properties;

import ai.people.core.security.entity.IgnoreUrls;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.Collections;
import java.util.Set;

/**
 * 资源服务属性
 *
 * @author yuanqinglong
 * @date 2022/4/16 16:44
 */
@Data
@ConfigurationProperties(prefix = "resource.security")
public class ResourceServiceProperties {

    /**
     * 资源id
     */
    private String resourceId = "c1";

    /**
     * 客户机id
     */
    private String clientId;

    /**
     * 客户秘密
     */
    private String clientSecret;

    /**
     * 不需要认证访问的url地址
     */
    private Set<String> ignoreUrls = Collections.emptySet();


    /**
     * 处理url
     *
     * @param ignoreUrl 忽略url
     * @return {@link IgnoreUrls}
     */
    public IgnoreUrls processingUrls(String ignoreUrl) {
        String strip = ignoreUrl.strip();
        String[] httpMethodAndUrl = strip.split("\\s+");
        return new IgnoreUrls(httpMethodAndUrl);
    }




}
